
<div class="layui-card-body">
    <!--<div class="layui-form-item" style="height: 38px;">
        <div class="layui-input-group">
            <input type="text" id="order_no" placeholder="请输入订单编号" class="layui-input" style="width: 300px">
            <div class="layui-input-suffix">
                <button class="layui-btn layui-btn-primary" id="search_btn">搜索订单</button>
            </div>
        </div>
        <button class="layui-btn layui-btn-normal" style="float: right;top: -37px;" id="confirm_btn">确认合箱</button>
    </div>-->
    <input type="hidden" id="packing_id" value="{$packing_id|default=0}">
    <table class="layui-table" id="goods_list" data-url="{:sysuri()}" data-target-search="form.form-search" lay-filter="goods_list"></table>
</div>

<script>
    $(function() {
        let table = layui.table;
        let packing_id = $('#packing_id').val();
        $('#goods_list').layTable({
            even: true, height: 'full',
            where: {id: packing_id},
            cols: [[
                {field: 'warehouse_name', title: '{:lang("仓库")}', minWidth: 150, align: 'center'  },
                // {field: 'platform_name', title: '{:lang("平台")}', minWidth: 150, align: 'center' , hide:!account_show },
                {field: 'account_name', title: '{:lang("公司ID")}', minWidth: 150, align: 'center'  },
                {field: 'order_no', title: '{:lang("订单号")}', minWidth: 150, align: 'center'  },
                {field: 'express_company', title: '{:lang("物流公司")}', minWidth: 100, align: 'center'  },
                {field: 'express_no', title: '{:lang("运单号码")}', minWidth: 150, align: 'center'},
                // {field: 'num', title: '{:lang("商品数量")}', minWidth: 150, align: 'center' },
                {field: 'location_code', title: '{:lang("货位")}', align: 'center', minWidth: 120, },
                {field: 'status_name', title: '{:lang("状态")}', align: 'center', minWidth: 120, },
                {field: 'into_time', title: '{:lang("入库时间")}', align: 'center', minWidth: 150, },
            ]]
        });

        $('#search_btn').on('click', function() {
            let order_no = $('#order_no').val();
            if(!isNotEmpty(order_no)) {
                return false;
            }
            table.reload('goods_list', {
                where: {order_no: order_no}
            });
        })

        $('#confirm_btn').on('click', function() {
            let list = table.checkStatus('goods_list')['data']; //获取选中行状态
            console.log(list);
            if(!isNotEmpty(list)) {
                layer.msg('{:lang("请勾选要操作的数据")}', {icon: 2});
                return false;
            }
            let ids = [];
            for (let i in list) {
                ids.push(list[i].id);
            }
            httpRequest('{:url("CombinePacking")}', {packing_ids: ids}, 'post', function(msg, res) {
                layer.msg(msg, {icon: 1});
                setTimeout(function() {
                    location.reload();
                }, 1000)
            })
        })
    })
</script>
